---
title: SDK
description: Interact with your infrastructure in your runtime code.
---

The SST SDK allows your runtime code to interact with your infrastructure in a typesafe way.

You can use the SDK in your **functions**, **frontends**, and **container applications**. You can access links from components. And some components come with SDK clients that you can use.

:::tip
Check out the _SDK_ section in a component's API reference doc.
:::

Currently, the SDK is only available for JS/TS, Python, Golang, and Rust. Support for other languages is on the roadmap.

---

## Node.js

The JS SDK is an [npm package](https://www.npmjs.com/package/sst) that you can install in your functions, frontends, or container applications.

```bash
npm install sst
```

---

### Links

Import `Resource` to access the linked resources.

```js title="src/lambda.ts"
import { Resource } from "sst";

console.log(Resource.MyBucket.name);
```

:::tip
The `Resource` object is typesafe and will autocomplete the available resources in your editor.
:::

Here we are assuming that a bucket has been linked to the function. Here's what that could look like.

```js title="sst.config.ts" {5}
const bucket = new sst.aws.Bucket("MyBucket");

new sst.aws.Function("MyFunction", {
  handler: "src/lambda.handler",
  link: [bucket]
});
```

---

#### Defaults

By default, the `Resource` object contains `Resource.App`. This gives you some info about the current app including:

- `App.name`: The name of your SST app.
- `App.stage`: The current stage of your SST app.

```ts title="src/lambda.ts"
import { Resource } from "sst";

console.log(Resource.App.name, Resource.App.stage);
```

---

### Clients

Components like the [`Realtime`](/docs/component/aws/realtime/) component come with a client that you can use.

```ts title="src/lambda.ts"
import { realtime } from "sst/aws/realtime";

export const handler = realtime.authorizer(async (token) => {
  // Validate the token
});
```

For example, `realtime.authorizer` lets you create the handler for the authorizer function that `Realtime` needs.

---

### How it works

In the above example, `Resource.MyBucket.name` works because it's been injected into the function package on `sst dev` and `sst deploy`.

For functions, this is injected into the [`globalThis`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis) using [esbuild](https://esbuild.github.io/) and for frontends, it's injected into the `process.env` object.

The JS SDK first checks the `process.env` and then the `globalThis` for the linked resources. You can [read more about how the links are injected](/docs/linking/#injecting-links).

---

## Python

SST uses [uv](https://docs.astral.sh/uv/) to package your Python functions. Your functions need to be in a [uv workspace](https://docs.astral.sh/uv/concepts/projects/workspaces/#workspace-sources).

To use the SDK, add it to your `pyproject.toml`.

```toml title="functions/pyproject.toml"
[tool.uv.sources]
sst = { git = "https://github.com/sst/sst.git", subdirectory = "sdk/python", branch = "dev" }
```

And in your function, import the `resource` module and access the linked resource.

```py title="functions/src/functions/api.py" {1} "Resource.MyBucket.name"
from sst import Resource

def handler(event, context):
    print(Resource.MyBucket.name)
```

Here `MyBucket` is the name of a bucket that's linked to the function.

```ts title="sst.config.ts" {6}
const bucket = new sst.aws.Bucket("MyBucket");

new sst.aws.Function("MyFunction", {
  handler: "functions/src/functions/api.handler",
  runtime: "python3.11",
  link: [bucket]
});
```

Client functions are currently **not supported** in the Python SDK.

---

## Golang

Use the SST Go SDK package in your Golang functions or container applications.

```go title="src/main.go"
import (
  "github.com/sst/sst/v3/sdk/golang/resource"
)
```

In your runtime code, use the `resource.Get` function to access the linked resources.

```go title="src/main.go"
resource.Get("MyBucket", "name")
```

Where `MyBucket` is the name of a bucket that's linked to the function.

```js title="sst.config.ts" {5}
const bucket = new sst.aws.Bucket("MyBucket");

new sst.aws.Function("MyFunction", {
  handler: "./src",
  link: [bucket]
});
```

You can also access the current app's info with.

```go title="src/main.go"
resource.Get("App", "name")
resource.Get("App", "stage")
```

Client functions are currently **not supported** in the Go SDK.

---

## Rust

Use the SST Rust SDK package in your Rust functions or container applications.

```toml title="Cargo.toml"
sst_sdk = "0.1.0"
```

In your runtime, use the `Resource::get()` function to access linked resources as a typesafe struct, or a `serde_json::Value`.

```rust title="main.rs"
use sst_sdk::Resource;

#[derive(serde::Deserialize, Debug)]
struct Bucket {
    name: String,
}

fn main() {
    let resource = Resource::init().unwrap();
    // access your linked resources as a typesafe struct that implements Deserialize
    let Bucket { name } = resource.get("MyBucket").unwrap();
    // or as a weakly typed json value (that also implements Deserialize)
    let openai_key: serde_json::Value = resource.get("OpenaiSecret").unwrap();
}
```

where `MyBucket` and `OpenaiSecret` are linked to the function.

```ts title="sst.config.ts"
const bucket = new sst.aws.Bucket("MyBucket");
const openai = new sst.Secret("OpenaiSecret");

new sst.aws.Function("MyFunction", {
  handler: "./",
  link: [bucket, openai],
  runtime: "rust"
});
```

Client functions are currently **not supported** in the Rust SDK.
